package com.dd.common.utils;

import com.dd.common.fileConstants.FileTypeSign;
import com.dd.common.fileConstants.FileSuffixCollection;

import java.util.Arrays;


/**
 * 文件工具类
 */
public class FileUtil {



    /**
     * 获取文件类型对应的数据
     * @param fileSuffix 文件后缀
     * @return
     */
    public static  Integer  getFileType(String fileSuffix){

        //图片文件
        if(Arrays.stream(FileSuffixCollection.imgTypeList).anyMatch(s->s.equals(fileSuffix))){
            return FileTypeSign.IMAGE_TYPE;
        }

        //文本文件
        else if(Arrays.stream(FileSuffixCollection.documentTypeList).anyMatch(s->s.equals(fileSuffix))){
           return  FileTypeSign.DOCUMENT_TYPE;
        }

        //视频文件
        else if(Arrays.stream(FileSuffixCollection.videoTypeList).anyMatch(s->s.equals(fileSuffix))){
            return  FileTypeSign.VIDEO_TYPE;
        }

        //音频文件
        else if(Arrays.stream(FileSuffixCollection.musicTypeList).anyMatch(s->s.equals(fileSuffix))){
            return  FileTypeSign.MUSIC_TYPE;
        }


        return FileTypeSign.ANOTHER_TYPE;
    }
}